package com.punch.punchtable.repository;


import com.punch.punchtable.entity.Sumup;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface SumupRepository extends JpaRepository<Sumup, Long>{

    @Query(value = "select distinct dept from sumup" ,nativeQuery = true)
    List<String> findAllDept();

//    @Transactional
//    @Modifying
//    @Query(value = "update sumup s,leader l set s.role=1 where s.usernum = l.leader_num ",nativeQuery = true)
//    String findAllByRole();

//    @Modifying
//    @Transactional
//    @Query(value = "insert into department (year,month,department,amount,late_amount,early_amount)\n" +
//            "(select year,month,dept as department,count(1) as amount,sum(userlate) as late_amount,sum(userearly) as early_amount from sumup s GROUP BY year,month,dept )", nativeQuery = true)
//    List<Department> list(Map<String, Object> paramMap);
     @Query(value = " SELECT Count(*) as Count" +
             " FROM sumup " +
             "GROUP BY dept,year,month", nativeQuery = true)
     List<Integer> deparmentlistCount();

}


